<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        count = 0;
        function start() {
            var obj = document.querySelector('#text');
            if (count == 0) {
                console.log(obj);
                txt = document.createTextNode('封校三天 快乐无边');
                obj.appendChild(txt);
                count = 1;
            } else if (count == 1) {
                obj.removeChild(txt);
                count = 0;
            }
            console.log(count);
            console.log(obj.innerHTML);
        }
    </script>
</head>

<body>
    <!-- 有个button,有个h2(封校三天 快乐无边),当点击button时会显示文字，再次点击会文字会消失。 -->
    <button onclick="start()">请点击</button>
    <div id="text"></div>
</body>

</html>